-- ==== BEGIN LICENSE BLOCK ====
-- storyboard-addon - Copyright (C) Arnaud Charnoz, 2006-2010.
-- Distributed under the terms of the GNU Lesser General Public License (LGPL) as
-- published by the Free Software Foundation.
-- ===== END LICENSE BLOCK ====

if sb == nil
then
    sb = {};
    if sb.ui == nil
    then
       sb.ui = {}; 
    end
end

sb.ui.StorylineEditorController = {};
sb.ui.StorylineEditorController.storyline = nil;

-------------------------------------------------------------------------------

function sb.ui.StorylineEditorController:init()

    sb_ui_StorylineEditorFrame_Title:SetText("Informations sur le scénario");
    
end

-------------------------------------------------------------------------------

function sb.ui.StorylineEditorController:setStoryline( newStoryline )

    self.storyline = newStoryline;
    self:setInfoToFrame();
    
end

-------------------------------------------------------------------------------

function sb.ui.StorylineEditorController:Show()

    SBMessageManager:debugMessage("sb.ui.StorylineEditorController:Show()");
    self:setInfoToFrame();
    sb_ui_StorylineEditorFrame:Show();
    
end

-------------------------------------------------------------------------------

function sb.ui.StorylineEditorController:IsVisible()

    return sb_ui_StorylineEditorFrame:IsVisible();
    
end

-------------------------------------------------------------------------------

function sb.ui.StorylineEditorController:Hide()

    sb_ui_StorylineEditorFrame:Hide();
    
end

-------------------------------------------------------------------------------

function sb.ui.StorylineEditorController:onSaveButton()
    
    self:getInfoFromFrame();
    
end

-------------------------------------------------------------------------------

function sb.ui.StorylineEditorController:setInfoToFrame()

    sb_ui_StorylineEditorFrame_titleValue:SetText                ( self.storyline:getTitle() );
    sb_ui_StorylineEditorFrame_numericVersionValue:SetText       ( self.storyline:getNumericVersion() );
    sb_ui_StorylineEditorFrame_textVersionValue:SetText          ( self.storyline:getTextVersion() );
    sb_ui_StorylineEditorFrame_authorAValue:SetText              ( self.storyline:getAuthorA() );
    sb_ui_StorylineEditorFrame_authorBValue:SetText              ( self.storyline:getAuthorB() );
    sb_ui_StorylineEditorFrame_authorCValue:SetText              ( self.storyline:getAuthorC() );
    sb_ui_StorylineEditorFrame_passwordValue:SetText             ( self.storyline:getPassword() );
    sb_ui_StorylineEditorFrame_factionRequirementValue:SetText   ( self.storyline:getFactionRequirement() );
    sb_ui_StorylineEditorFrame_levelRequirementValue:SetText     ( self.storyline:getLevelRequirement() );
    sb_ui_StorylineEditorFrame_otherRequirementsValue:SetText    ( self.storyline:getOtherRequirements() );
    sb_ui_StorylineEditorFrame_abstractScrollFrame_Value:SetText             ( self.storyline:getAbstract() );
    sb_ui_StorylineEditorFrame_starterScrollFrame_Value:SetText              ( self.storyline:getStarter() );
    
end

-------------------------------------------------------------------------------

function sb.ui.StorylineEditorController:getInfoFromFrame()

    self.storyline:setTitle(                sb_ui_StorylineEditorFrame_titleValue:GetText() );
    self.storyline:setNumericVersion(       tonumber( sb_ui_StorylineEditorFrame_numericVersionValue:GetText() ) );
    self.storyline:setTextVersion(          sb_ui_StorylineEditorFrame_textVersionValue:GetText() );
    self.storyline:setAuthorA(              sb_ui_StorylineEditorFrame_authorAValue:GetText() );
    self.storyline:setAuthorB(              sb_ui_StorylineEditorFrame_authorBValue:GetText() );
    self.storyline:setAuthorC(              sb_ui_StorylineEditorFrame_authorCValue:GetText() );
    self.storyline:setPassword(             sb_ui_StorylineEditorFrame_passwordValue:GetText() );
    self.storyline:setFactionRequirement(   sb_ui_StorylineEditorFrame_factionRequirementValue:GetText() );
    self.storyline:setLevelRequirement(     sb_ui_StorylineEditorFrame_levelRequirementValue:GetText() );
    self.storyline:setOtherRequirements(    sb_ui_StorylineEditorFrame_otherRequirementsValue:GetText() );
    self.storyline:setAbstract(             sb_ui_StorylineEditorFrame_abstractScrollFrame_Value:GetText() );
    self.storyline:setStarter(              sb_ui_StorylineEditorFrame_starterScrollFrame_Value:GetText() );
    
end

-------------------------------------------------------------------------------
